home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / voxel101.zip / VOIXELMI.REX < prev    next >
OS/2 REXX Batch file  |  1994-02-06  |  5KB  |  226 lines

  1. /* Mini TERM BBS (c) 1993 The Brazilian (bmaple@burner.com)
  2. **
  3. */
  4.  
  5. address TERM
  6. options results                 /* Gets info back from Term              */
  7.  
  8. password = 'SECRET'
  9. curdir = 'Work:'
  10. Retries = 3
  11.  
  12. call TIME('R')
  13.  
  14. say "MiniBBS (c) 1993 The Brazilian"
  15. say "bmaple@burner.com"
  16. say ""
  17. say "New features added by Christian Mag Magnusson."
  18. say "This only a test how to use the Data connection from VoiXEL"
  19. say "VoiXELminiBBS V1.00"
  20.  
  21. ANSWER:
  22.  
  23.    TIMEOUT SEC 70               /* Set term's expect time-out to 70 sec */
  24.    SEND 'AT^M'                  /* Replace w/setup string of choice     */
  25.    DELAY SEC 1
  26.  
  27. CYCLE:
  28.  
  29.    CLEAR WAIT                       /* Clear's term's expect string list    */
  30.    ADDITEM TO WAIT NAME "CONN"        /* Get term to return when "CONNECT"    */
  31.    ADDITEM TO WAIT NAME "NO CARRIER"/* Get term to return when "NO CARRIER" */
  32.    SEND 'ATA^M'                     /* Answer phone at once                 */
  33.    WAIT
  34.    Res = result                        /* The whole string term matched        */
  35.  
  36.    /* term will return from the WAIT after the timeout length is        */
  37.    /* exceeded, or it gets one of the strings on the wait list.         */
  38.    /* For this reason, we have to actualy CHECK what term returns to    */
  39.    /* find out if it's a 'RING', or if it timed out and got noting..    */
  40.  
  41.     if rc ~= 0 then
  42.         do
  43.             QUITBBS(10);
  44.         end
  45.     else
  46.     if upper( left( Res, 4 ) ) = 'CONN' then
  47.         do
  48.             DELAY MIC 20              /* 20 microsecs; some modems need this   */
  49.  
  50.             GETATTR TERM.SESSION.CONNECTMESSAGE
  51.  
  52.             DELAY SEC 1
  53.  
  54.            /* At this point we'll set the timeout to 70 seconds,        */
  55.            /* otherwise MiniBBS will log them off after only 20 seconds */
  56.            /* of non-activity.                                          */
  57.  
  58.             TIMEOUT SEC 20               /* Set 'idle logoff' time       */
  59.  
  60.            /* START mini BBS stuff */
  61.            /************************/
  62.  
  63.             call CLS
  64.             SEND '^M^JWelcome to VoiXEL''s MiniBBS V1.00!^M^J^M^J'
  65. RETYPEPASSWORD:
  66.             SEND '"' || 'Password: ' || '"'
  67.             READ CR NOECHO   ; UsrPass = result
  68.  
  69.                if upper(UsrPass) = upper(Password) then
  70.                 do
  71.                     TIMEOUT SEC 60               /* Set 'idle logoff' time       */
  72.                        SEND '  Welcome!^M^J^M^J'
  73.                     DELAY SEC 1
  74.  
  75.                     LOOP:
  76.  
  77.                     call CLS
  78.                     SEND '^M^JMiniBBS Main Menu^M^J-----------------^M^J^M^J'
  79.                     SEND 'U. Upload file^M^J'
  80.                     SEND 'D. Download file^M^J'
  81.                     SEND 'C. Change Directory^M^J'
  82.                     SEND 'S. Show Directory (Dir)^M^J'
  83.                     SEND 'L. List Directory (List)^M^J'
  84.                     SEND 'G. Loggoff^M^J^M^J'
  85.                     SEND 'Choose a command:  '
  86.                       READ CR;input = result
  87.  
  88.                     if rc ~= 0 then
  89.                         QUITBBS (1)
  90.                     else if input = 'U' then call Upload
  91.                       else if input = 'D' then call Download
  92.                       else if input = 'C' then call ChangeDir
  93.                       else if input = 'S' then call Dir
  94.                       else if input = 'L' then call LIST
  95.                       else if input = 'G' then call QUITBBS(0)
  96.                       else call LOOP
  97.                 end
  98.               else
  99.                 do                      /* Bad password! */
  100.                       SEND 'Bad password.^M^J^M^J'
  101.                     Retries = Retries - 1
  102.                     if Retries > 0 then
  103.                         do
  104.                             call RETYPEPASSWORD
  105.                         end
  106.                     else
  107.                         do
  108.                             call QUITBBS(2)
  109.                         end
  110.                 end
  111.         end
  112.     else
  113.     if upper( left( Res, 10 ) ) = 'NO CARRIER' then
  114.         do
  115.             QUITBBS(9)
  116.         end
  117.     else
  118.         do
  119.             QUITBBS(8)
  120.         end
  121. exit
  122.  
  123.  
  124. QUITBBS: parse arg retcode
  125.     SEND '^M^J^M^JGood bye...^M^J^M^J'
  126.     HANGUP
  127. say TRUNC(TIME('E'))
  128.     ADDRESS VOIXELPORT 'SetVAR LENGTH ' || TRUNC(TIME('E'))
  129.     if retcode=0 then
  130.         do
  131.             ADDRESS VOIXELPORT 'SetVAR CALLERNUMBER OK'
  132.         end
  133.     else
  134.         do
  135.             ADDRESS VOIXELPORT 'SetVAR CALLERNUMBER ' || retcode
  136.         end
  137.     QUIT FORCE                            /* Term MUST exit after logoff */
  138.     exit
  139.  
  140. CHANGEDIR:
  141.     SEND '^M^J^M^JCurrent Path : ' || curdir
  142.     SEND '^M^JChange Directory To : '
  143.     READ CR ; NewDir = result
  144.     if Exists(NewDir) then
  145.         do
  146.             curdir = NewDir
  147.         end
  148.     else
  149.         do
  150.             SEND 'File/Directory not found^M^J^M^J'
  151.         end
  152.     return
  153.  
  154.  
  155. DIR:
  156.     EXECTOOL COMMAND 'VoiXEL:showdir ' || curdir
  157.     SENDFILE MODE ASCII 't:dirtmp'
  158.     return
  159.  
  160. LIST:
  161.     EXECTOOL COMMAND 'VoiXEL:listdir ' || curdir
  162.     SENDFILE MODE ASCII 't:dirtmp'
  163.     return
  164.  
  165. UPLOAD:
  166.    SEND '^M^J^M^JReady to receive file (ZModem).  Send at will.^M^J'
  167.    RECEIVEFILE
  168.  
  169.    DELAY SEC 5
  170.    SEND '^M^JComplete.^M^J^M^J'
  171.  
  172.    SELECTITEM FROM DOWNLOAD TOP
  173.  
  174.    do while rc = 0
  175.       SEND 'UL File: ' || result
  176.       SELECTITEM FROM DOWNLOAD NEXT
  177.    end
  178.    CLEAR DOWNLOAD
  179.    return
  180.  
  181.  
  182. DOWNLOAD:
  183.  
  184.    SEND '^M^J^M^JCurrent Path : ' || curdir
  185.    SEND '^M^JFilename: '
  186.    READ CR;filename = result
  187.  
  188.    if rc ~= 0 then
  189.         do
  190.             SEND '^M^J^M^JYou didn''t enter any filename^M^J^M^J'
  191.               DELAY SEC 2
  192.             return
  193.         end
  194.    else
  195.    if Exists( curdir || filename ) then
  196.         do
  197.               SAY  'DL File: 'filename
  198.               SEND '^M^J^M^JSending file..^M^J^M^J'
  199.               SENDFILE filename
  200.  
  201.               DELAY SEC 3
  202.               SEND '^M^JComplete.^M^J^M^J'
  203.               return
  204.            end
  205.    else
  206.    if Exists( curdir || '/' || filename ) then
  207.         do
  208.               SAY  'DL File: 'filename
  209.               SEND '^M^J^M^JSending file..^M^J^M^J'
  210.               SENDFILE filename
  211.  
  212.               DELAY SEC 3
  213.               SEND '^M^JComplete.^M^J^M^J'
  214.               return
  215.         end
  216.    else
  217.         do
  218.             SEND '^M^J^M^JFile not found.^M^J^M^J'
  219.               DELAY 2 SEC
  220.               return
  221.         end
  222.  
  223. CLS:
  224.    SEND d2c(12)
  225.    return
  226.